Crate standback[][src]

Standback backports a number of methods, structs, and macros that have been stabilized in the Rust standard library since 1.31.0. This allows crate authors to depend on Standback rather than forcing downstream users to upgrade their compiler (or not use the new feature at all).

Due to a variety of restrictions in the Rust, it is not possible to implement everything that has been stabilized.

Usage

For most cases, importing the prelude should suffice.

use standback::prelude::*;

If you are using anything that would normally have to be imported, just use the standback crate instead of core, alloc, or std.

use standback::mem::take;

It is highly recommended to use #![allow(unstable_name_collisions)], as that’s the whole point of this crate. Just be extra-careful to not do it for anything that can’t be backported.

#![no_std] support

By default, there standard library is used where necessary. If support for #![no_std] is required, use default-features = false.

An allocator is not required for any backported item. If any require an allocator in the future, it will be gated under an alloc feature.

Inherent and trait methods, associated constants

The following methods and constants are available via the prelude. For brevity, i* is i8, i16, i32, i64, i128, and isize; u* is u8, u16, u32, u64, u128, and usize.

1.51

Arc::decrement_strong_count
Arc::increment_strong_count
Peekable::next_if_eq
Peekable::next_if
Seek::stream_position
slice::fill_with
slice::split_inclusive_mut
slice::split_inclusive
slice::strip_prefix
slice::strip_suffix
task::Wake // requires rustc 1.33
i*::unsigned_abs
Poll::map_ok
Poll::map_err

1.50

bool::then
btree_map::Entry::or_insert_with_key
hash_map::Entry::or_insert_with_key
{f32, f64}::clamp
Ord::clamp
RefCell::take
slice::fill
UnsafeCell::get_mut

1.49

slice::select_nth_unstable
slice::select_nth_unstable_by
slice::select_nth_unstable_by_key

1.48

slice::as_ptr_range
slice::as_mut_ptr_range

1.47

Range::is_empty
Result::as_deref
Result::as_deref_mut
Vec::leak
f32::TAU
f64::TAU

1.46

{i*, u*}::leading_ones
{i*, u*}::trailing_ones
Option::zip

1.45

i*::saturating_abs
i*::saturating_neg

1.44

PathBuf::with_capacity
PathBuf::capacity
PathBuf::clear
PathBuf::reserve
PathBuf::reserve_exact
PathBuf::shrink_to_fit
Layout::align_to
Layout::pad_to_align
Layout::array
Layout::extend
{f32, f64}::to_int_unchecked

1.43

{f32, f64}::RADIX
{f32, f64}::MANTISSA_DIGITS
{f32, f64}::DIGITS
{f32, f64}::EPSILON
{f32, f64}::MIN
{f32, f64}::MIN_POSITIVE
{f32, f64}::MAX
{f32, f64}::MIN_EXP
{f32, f64}::MAX_EXP
{f32, f64}::MIN_10_EXP
{f32, f64}::MAX_10_EXP
{f32, f64}::NAN
{f32, f64}::INFINITY
{f32, f64}::NEG_INFINITY
{i*, u*}::MIN
{i*, u*}::MAX

1.42

CondVar::wait_while
CondVar::wait_timeout_while
ManuallyDrop::take

1.41

Result::map_or
Result::map_or_else

1.40

Option::as_deref
Option::as_deref_mut
{f32, f64}::to_be_bytes
{f32, f64}::to_le_bytes
{f32, f64}::to_ne_bytes
{f32, f64}::from_be_bytes
{f32, f64}::from_le_bytes
{f32, f64}::from_ne_bytes
slice::repeat

1.39

None :(

1.38

<*const T>::cast
<*mut T>::cast
Duration::as_secs_f32
Duration::as_secs_f64
Duration::div_f32
Duration::div_f64
Duration::from_secs_f32
Duration::from_secs_f64
Duration::mul_f32
Duration::mul_f64
{i*, u*}::rem_euclid
{i*, u*}::checked_rem_euclid
{i*, u*}::wrapping_rem_euclid
{i*, u*}::overflowing_rem_euclid
{i*, u*}::div_euclid
{i*, u*}::checked_div_euclid
{i*, u*}::wrapping_div_euclid
{i*, u*}::overflowing_div_euclid
{f32, f64}::rem_euclid
{f32, f64}::div_euclid

1.37

Cell::from_mut
Cell<[T]>::as_slice_of_cells
DoubleEndedIterator::nth_back
Option::xor
slice::copy_within

1.36

Iterator::copied
mem::MaybeUninit
task::Context
task::RawWaker
task::RawWakerVTable
task::Waker
task::Poll

1.35

RefCell::replace_with
ptr::hash
Range::contains
RangeFrom::contains
RangeTo::contains
RangeInclusive::contains
RangeToInclusive::contains
Option::copied

1.34

slice::sort_by_cached_key
{i*, u*}::checked_pow
{i*, u*}::saturating_pow
{i*, u*}::wrapping_pow
{i*, u*}::overflowing_pow

1.33

os::unix::fs::FileExt::read_exact_at
os::unix::fs::FileExt::write_all_at
Option::transpose
Result::transpose
VecDeque::resize_with
Duration::as_millis
Duration::as_micros
Duration::as_nanos

1.32

{i*, u*}::to_be_bytes
{i*, u*}::to_le_bytes
{i*, u*}::to_ne_bytes
{i*, u*}::from_be_bytes
{i*, u*}::from_le_bytes
{i*, u*}::from_ne_bytes

Free functions and constants

future::pending // 1.48, requires rustc 1.36
future::ready // 1.48, requires rustc 1.36
char::UNICODE_VERSION // 1.45
{f32, f64}::consts::LOG10_2 // 1.43
{f32, f64}::consts::LOG2_10 // 1.43
iter::once_with // 1.43
mem::take // 1.40
iterator::Copied // 1.36
array::TryFromSliceError // 1.36
iter::from_fn // 1.34
iter::successors // 1.34
convert::TryFrom // 1.34
convert::TryInto // 1.34
num::TryFromIntError // 1.34
convert::identity // 1.33
pin::Pin // 1.33
marker::Unpin // 1.33

Macros

matches! // 1.42
todo! // 1.39